require("UIApplication, NRWCarUser, CarInputChooseBrandVC, CarVinAuthOCRVC, NRWCarTurnTime, NRWCarTurnTime, NRWCarTurnTime, NSMutableArray, NSMutableArray, NSMutableArray, NSMutableArray, Basecaroutcoloroptions, NSMutableArray, NSMutableArray, Basecarincoloroptions, NSMutableArray, NSMutableArray, NSMutableArray, NSMutableArray, NSMutableArray, NSMutableArray, Basecarpurposeoptions");

defineClass("CarInputVC", {
            tableView_didSelectRowAtIndexPath: function(tableView, indexPath) {
            tableView.deselectRowAtIndexPath_animated(indexPath, YES);
            UIApplication.sharedApplication().keyWindow().endEditing(YES);
            if (indexPath.row() == 0) {
            self.loadMarketList();
            } else if (indexPath.row() == 1) {
            if (NRWCarUser.sharedUser().shopId()) {} else {
            self.loadShopList();
            }
            } else if (indexPath.row() == 3) {
            var brandVC = CarInputChooseBrandVC.alloc().init();
            brandVC.setFromControllerClass(self.class());
            self.navigationController().pushViewController_animated(brandVC, YES);
            } else if (indexPath.row() == 2) {
            var codeVC = CarVinAuthOCRVC.alloc().init();
            kSelfWeak;
            codeVC.setGetVin(block("void, NSString*, NSString*, BOOL", function(vin, time, istureVin) {
                                    var slf = self;
                                   self.valueForKey("_carNum") = vin;
                                   if (isEmptyOrNilString(time) == NO) {
                                   var lenght = time.length();
                                   self.valueForKey("_firstDate")  = time.substringToIndex(lenght - 3);
                                   self.valueForKey("_LicenseID") = "1";
                                   var yearNum = NRWCarTurnTime.formateFirstDate_withFormate(time, "yyyy-MM-dd");
                                   self.valueForKey("_checkDate") = NRWCarTurnTime.returnDate_withFormate_withYearNum_withType(time, "yyyy-MM-dd", yearNum, YES);
                                   self.valueForKey("_strongDate") = self.valueForKey("_bizDate") = NRWCarTurnTime.returnDate_withFormate_withYearNum_withType(time, "yyyy-MM-dd", yearNum, NO);
                                   self.setIsExpire(NO);
                                   }
                                   if (istureVin == YES) {
                                   weakSelf.loadCarInfoFromVinCode(self.valueForKey("_carNum"));
                                   }
                                   weakSelf.tableview().reloadData();
                                   }));
            self.navigationController().pushViewController_animated(codeVC, YES);
            } else if (indexPath.row() == 6) {
            var names = NSMutableArray.alloc().initWithObjects("已上牌", "未上牌", "新车", null);
            self.creatChoose_tag(names, 4);
            } else if (indexPath.row() == 7) {
            self.CreatDateChoose(0);
            } else if (indexPath.row() == 8) {
            self.CreatDateChoose(2);
            } else if (indexPath.row() == 10) {
            self.CreatDateChoose(3);
            } else if (indexPath.row() == 11) {
            self.CreatDateChoose(4);
            } else if (indexPath.row() == 12) {
            var names = NSMutableArray.alloc().initWithObjects("1", "2", "3", "4", null);
            self.creatChoose_tag(names, 5);
            } else if (indexPath.row() == 13) {
            var colornames = NSMutableArray.array();
            var colorImages = NSMutableArray.array();
            for (NSDictionary * dic in self.otherModel().result().baseCarOutColorOptions()) {
            var outColor = Basecaroutcoloroptions.mj__objectWithKeyValues(dic);
            colornames.addObject(outColor.colorName());
            colorImages.addObject(outColor.colorCode());
            self.colorsArray().addObject(outColor.colorId());
            }
            self.creatChooseColor_ColorValue_tag(colornames, colorImages, 0);
            } else if (indexPath.row() == 14) {
            var colornames = NSMutableArray.array();
            var colorImages = NSMutableArray.array();
            for (NSDictionary * dic in self.otherModel().result().baseCarInColorOptions()) {
            var inColor = Basecarincoloroptions.mj__objectWithKeyValues(dic);
            colornames.addObject(inColor.colorName());
            colorImages.addObject(inColor.colorCode());
            }
            self.creatChooseColor_ColorValue_tag(colornames, colorImages, 1);
            } else if (indexPath.row() == 15) {
            var typeNames = NSMutableArray.array();
            self.setTypeIds(NSMutableArray.array());
            for (NSDictionary * dic in self.otherModel().result().baseCarTypeOptions()) {
            var type = baseCarTypeOptions.mj__objectWithKeyValues(dic);
            typeNames.addObject(type.carTypeName());
            self.typeIds().addObject(type.carTypeId());
            }
            self.creatChoose_tag(typeNames, 6);
            } else if (indexPath.row() == 16) {
            var mArray = NSMutableArray.arrayWithArray(self.otherModel().result().baseCarGearboxOptions());
            self.creatChoose_tag(mArray, 7);
            } else if (indexPath.row() == 18) {
            var names = NSMutableArray.alloc().initWithObjects("L", "T", null);
            self.creatChoose_tag(names, 8);
            } else if (indexPath.row() == 21) {
            var userNames = NSMutableArray.array();
            self.setUseKeys(NSMutableArray.array());
            for (NSDictionary * dic in self.otherModel().result().baseCarPurposeOptions()) {
            var user = Basecarpurposeoptions.mj__objectWithKeyValues(dic);
            userNames.addObject(user.purposeValue());
            self.useKeys().addObject(user.purposeKey());
            }
            self.creatChoose_tag(userNames, 9);
            }
            }
            }, {});
